import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//用来测试浏览器接收cookie对象，进而获取cookie对象所保存的数据
public class cookie01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //从request对象中获取所有提交的cookie
        Cookie[] cookies=request.getCookies();
            if(cookies != null){
                for (Cookie cookie:cookies) {
                    String cookieName=cookie.getName();
                    String cookieValue=cookie.getValue();
                    System.out.println(cookieName+"="+cookieValue);
            }
        }
    }
}
